Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
interface System.​Numerics.​IBinaryInteger<​TSelf>
Assembly: System.Runtime
Implemented Interfaces
- IBinaryNumber`1 (Inherits: IComparableIComparable<​TSelf>IEquatable<​TSelf>IFormattableIParsable<​TSelf>ISpanFormattableISpanParsable<​TSelf>IAdditionOperators<​TSelf, TSelf, TSelf>IAdditiveIdentity<​TSelf, TSelf>IBitwiseOperators<​TSelf, TSelf, TSelf>IComparisonOperators<​TSelf, TSelf, bool>IEqualityOperators<​TSelf, TSelf, bool>IDecrementOperators<​TSelf>IDivisionOperators<​TSelf, TSelf, TSelf>IIncrementOperators<​TSelf>IModulusOperators<​TSelf, TSelf, TSelf>IMultiplicativeIdentity<​TSelf, TSelf>IMultiplyOperators<​TSelf, TSelf, TSelf>INumber<​TSelf>INumberBase<​TSelf>IUtf8SpanFormattableIUtf8SpanParsable<​TSelf>ISubtractionOperators<​TSelf, TSelf, TSelf>IUnaryNegationOperators<​TSelf, TSelf>IUnaryPlusOperators<​TSelf, TSelf>)
- IShiftOperators`3
Defines an integer type that is represented in a base-2 format.
Methods
static
ValueTuple<​TSelf, TSelf>
DivRem​(TSelf left,
TSelf right)
Computes the quotient and remainder of two values.
Returns The quotient and remainder of <paramref name="left" /> divided by <paramref name="right" /> .
left
The value that <paramref name="right" /> divides.
right
The value that divides <paramref name="left" /> .
int
GetByteCount​()
Gets the number of bytes that will be written as part of <see cref="M:System.Numerics.IBinaryInteger`1.TryWriteLittleEndian(System.Span{System.Byte},System.Int32@)" /> .
Returns The number of bytes that will be written as part of <see cref="M:System.Numerics.IBinaryInteger`1.TryWriteLittleEndian(System.Span{System.Byte},System.Int32@)" /> .
int
GetShortestBitLength​()
Gets the length, in bits, of the shortest two's complement representation of the current value.
Returns The length, in bits, of the shortest two's complement representation of the current value.
static
TSelf
LeadingZeroCount​(TSelf value)
Computes the number of leading zero bits in a value.
Returns The number of leading zero bits in <paramref name="value" /> .
value
The value whose leading zero bits are to be counted.
static
TSelf
PopCount​(TSelf value)
Computes the number of bits that are set in a value.
Returns The number of set bits in <paramref name="value" /> .
value
The value whose set bits are to be counted.
static
TSelf
ReadBigEndian​(byte[] source,
bool isUnsigned)
Reads a two's complement number from a given array, in big-endian format, and converts it to an instance of the current type.
Returns The value read from <paramref name="source" /> .
source
The array from which the two's complement number should be read.
isUnsigned
<see langword="true" /> if <paramref name="source" /> represents an unsigned two's complement number; otherwise, <see langword="false" /> to indicate it represents a signed two's complement number.
static
TSelf
ReadBigEndian​(byte[] source,
int startIndex,
bool isUnsigned)
Reads a two's complement number from a given array, in big-endian format, and converts it to an instance of the current type.
Returns The value read from <paramref name="source" /> starting at <paramref name="startIndex" /> .
source
The array from which the two's complement number should be read.
startIndex
The starting index from which the value should be read.
isUnsigned
<see langword="true" /> if <paramref name="source" /> represents an unsigned two's complement number; otherwise, <see langword="false" /> to indicate it represents a signed two's complement number.
static
TSelf
ReadBigEndian​(ReadOnlySpan<​byte> source,
bool isUnsigned)
Reads a two's complement number from a given span, in big-endian format, and converts it to an instance of the current type.
Returns The value read from <paramref name="source" /> .
source
The array from which the two's complement number should be read.
isUnsigned
<see langword="true" /> if <paramref name="source" /> represents an unsigned two's complement number; otherwise, <see langword="false" /> to indicate it represents a signed two's complement number.
static
TSelf
ReadLittleEndian​(byte[] source,
bool isUnsigned)
Reads a two's complement number from a given array, in little-endian format, and converts it to an instance of the current type.
Returns The value read from <paramref name="source" /> .
source
The array from which the two's complement number should be read.
isUnsigned
<see langword="true" /> if <paramref name="source" /> represents an unsigned two's complement number; otherwise, <see langword="false" /> to indicate it represents a signed two's complement number.
static
TSelf
ReadLittleEndian​(byte[] source,
int startIndex,
bool isUnsigned)
Reads a two's complement number from a given array, in little-endian format, and converts it to an instance of the current type.
Returns The value read from <paramref name="source" /> starting at <paramref name="startIndex" /> .
source
The array from which the two's complement number should be read.
startIndex
The starting index from which the value should be read.
isUnsigned
<see langword="true" /> if <paramref name="source" /> represents an unsigned two's complement number; otherwise, <see langword="false" /> to indicate it represents a signed two's complement number.
static
TSelf
ReadLittleEndian​(ReadOnlySpan<​byte> source,
bool isUnsigned)
Reads a two's complement number from a given span, in little-endian format, and converts it to an instance of the current type.
Returns The value read from <paramref name="source" /> .
source
The array from which the two's complement number should be read.
isUnsigned
<see langword="true" /> if <paramref name="source" /> represents an unsigned two's complement number; otherwise, <see langword="false" /> to indicate it represents a signed two's complement number.
static
TSelf
RotateLeft​(TSelf value,
int rotateAmount)
Rotates a value left by a given amount.
Returns The result of rotating <paramref name="value" /> left by <paramref name="rotateAmount" /> .
value
The value that is rotated left by <paramref name="rotateAmount" /> .
rotateAmount
The amount by which <paramref name="value" /> is rotated left.
static
TSelf
RotateRight​(TSelf value,
int rotateAmount)
Rotates a value right by a given amount.
Returns The result of rotating <paramref name="value" /> right by <paramref name="rotateAmount" /> .
value
The value that is rotated right by <paramref name="rotateAmount" /> .
rotateAmount
The amount by which <paramref name="value" /> is rotated right.
static
TSelf
TrailingZeroCount​(TSelf value)
Computes the number of trailing zero bits in a value.
Returns The number of trailing zero bits in <paramref name="value" /> .
value
The value whose trailing zero bits are to be counted.
static
bool
TryReadBigEndian​(ReadOnlySpan<​byte> source,
bool isUnsigned,
TSelf& value)
static
bool
TryReadLittleEndian​(ReadOnlySpan<​byte> source,
bool isUnsigned,
TSelf& value)
bool
TryWriteLittleEndian​(Span<​byte> destination,
Int32& bytesWritten)
int
WriteBigEndian​(byte[] destination)
Writes the current value, in big-endian format, to a given array.
Returns The number of bytes written to <paramref name="destination" /> .
destination
The array to which the current value should be written.
int
WriteBigEndian​(byte[] destination,
int startIndex)
Writes the current value, in big-endian format, to a given array.
Returns The number of bytes written to <paramref name="destination" /> starting at <paramref name="startIndex" /> .
destination
The array to which the current value should be written.
startIndex
The starting index at which the value should be written.
int
WriteBigEndian​(Span<​byte> destination)
Writes the current value, in big-endian format, to a given span.
Returns The number of bytes written to <paramref name="destination" /> .
destination
The span to which the current value should be written.
int
WriteLittleEndian​(byte[] destination)
Writes the current value, in little-endian format, to a given array.
Returns The number of bytes written to <paramref name="destination" /> .
destination
The array to which the current value should be written.
int
WriteLittleEndian​(byte[] destination,
int startIndex)
Writes the current value, in little-endian format, to a specified array starting at a specified index.
Returns The number of bytes written to <paramref name="destination" /> starting at <paramref name="startIndex" /> .
destination
The array to which the current value should be written.
startIndex
The starting index at which the value should be written.
int
WriteLittleEndian​(Span<​byte> destination)
Writes the current value, in little-endian format, to a given span.
Returns The number of bytes written to <paramref name="destination" /> .
destination
The span to which the current value should be written.